var common = {
  res_url: '/api/',
  post_func(url, data, cellback) {
    var _this = this;
    var token = localStorage.getItem('token');
    var username = localStorage.getItem('user');
    $.ajax({
      type: "POST",
      url: this.res_url + url,
      data: data,
      async: true,
      headers: {
        "token": token,
        "username": username
      },
      success: function (res) {
        cellback(res)
      },
      error: function () {
        alert("网络错误")
      }
    })
  },
  upload_img(url, data, cellback) {
    var _this = this
    var token = localStorage.getItem('token')
    var username = localStorage.getItem('user')
    $.ajax({
      type: "POST",
      url: this.res_url + url,
      data: data,
      async: false,
      cache: false,
      contentType: false,
      processData: false,
      headers: {
        "token": token,
        "username": username
      },
      success: function (res) {
        cellback(res)
      },
      error: function () {
        alert("网络错误")
      }
    })
  }
}
module.exports = common
